export default {
	name: 'Menus',
	data() {
		return {
			//数据
			faindex: null, //一级菜单默认index
			changindex: null, //二级级菜单默认index
			changindexS: null, //三级级菜单默认index
			items: [{
				id: "1",
				name: '我的桌面',
				isSubShow: false,
				src: "./static/images/Personal/desktop1.png",
				path: "myDesktop",
			}, {
				id: "2",
				name: '基地管理',
				isSubShow: false,
				src: "./static/images/Personal/management1.png",
				path: "",
			}, {
				id: "3",
				name: '基地审核',
				isSubShow: false,
				src: "./static/images/Personal/audit1.png",
				path: "",
				subItems: [{
					name: '形式审查',
					path: ""
				}, {
					name: '基地评审',
					path: ""
				}, {
					name: '基地评审',
					path: ""
				}]
			}, ]

		}
	},
	created() { //调用方法
	},
	mounted() {

	},
	methods: { //写函数方法
		shows: function() {
			this.showPrise = false;
		},
		//判断当前路径
		getPath:function(){
			var pathName = window.document.location.href;
			var path=pathName.substring(pathName.lastIndexOf("/"))
			console.log(this.items);
			for(var i=0;i<this.items.length;i++){
				for(var k=0;k<this.items[i].subItems.length;k++){
					if(this.items[i].subItems[k].subItems!=null&&
						this.items[i].subItems[k].subItems.length>0)
					{
						for(var j=0;j<this.items[i].subItems[k].subItems.length;j++){
							if(this.items[i].subItems[k].subItems[j].path==path){
//								console.log('三级赋值',this.items[i].subItems[k].subItems[j].id)
								this.faindex=this.items[i].id
								this.changindex=this.items[i].subItems[k].id
								this.changindexS=this.items[i].subItems[k].subItems[j].id
							}
						}
					}
					if(this.items[i].subItems[k].path==path){
//						console.log('二级赋值',this.items[i].subItems[k].id)
						this.faindex=this.items[i].id
						this.changindex=this.items[i].subItems[k].id
						this.changindexS=0
					}
				}
				if(this.items[i].path==path){
//					console.log('一级赋值',this.items[i].id)
					this.faindex=this.items[i].id
					this.changindex=0
					this.changindexS=0
				}
			}
		},
		showToggle: function(item) {
			this.$router.push({
				path: item.path
			})
			this.getPath();
		},
		clickChild: function(subItem) {
			this.$router.push({
				path: subItem.path
			})
			this.getPath();
		},
		clickChildS: function(subItem) {
			this.$router.push({
				path: subItem.path
			})
			this.getPath();
		},

	},

}